Skip to content

fix(context): restore skills after compaction - #9043

Merged
NicholasRBowers merged 1 commit into
kirodotdev:mainfrom
Premshay:upstream/native-compaction-context-recovery
Sep 17, 2026
Merged

NicholasRBowers merged 1 commit into
kirodotdev:mainfrom
Premshay:upstream/native-compaction-context-recovery

Conversation

@Premshay

@Premshay Premshay commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Provider-native and manual ACP compaction replace the model context but do not arm the existing one-shot skills-context reinjection. The next user turn can therefore no longer discover the skills available to the session.

Why it matters

Compaction is meant to preserve an ongoing session. Losing the skills index after it completes makes tool and workflow discovery depend on a restart rather than the normal next turn.

What changed

Arm the existing mark_needs_reinjection flag when a native compaction completes, including immediate Claude completion, deferred Kiro completion, and provider-emitted completion status. The next turn consumes the flag through the established prompt-building path.

Pattern harvest

Rule candidate: review-prompt
Pattern: Provider context replacement must rearm session-start context.

When a provider mutates or replaces its context outside the normal session lifecycle, rearm durable session-start context at the completion event. Reuse the existing one-shot reinjection seam rather than duplicating prompt assembly in each provider path.

Tests

PYTHONPATH=src /home/prems/dev/repos/premshay/KiroCrew/.venv/bin/pytest -q test/test_dashboard_chat.py -n0 — 767 passed.

What changed (motivation → approach → change)

N/A — covered by the existing ## What changed section.

Manual verification

N/A — focused automated coverage is sufficient.

Related Issues

N/A.

Checklist

  • Existing tests pass and regression coverage is included.
  • Self-review completed; code follows project style guidelines.
  • Documentation updated where applicable.
  • No secrets, credentials, or internal references in the diff.

Contribution License Agreement

N/A — template placeholder; no CLA wording is supplied.

@Premshay
Premshay requested review from a team and bolichen97 September 6, 2026 14:38
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 6, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

1 similar comment
@dwu96

dwu96 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@Premshay
Premshay force-pushed the upstream/native-compaction-context-recovery branch from 35c7c9b to df70886 Compare September 6, 2026 15:07
@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed a76f976ac01683e2d95072fda3980637fb86ea9f via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a76f976

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed a76f976ac01683e2d95072fda3980637fb86ea9f via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] a76f976

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🟡 CONCERNS

Design-level review of a76f976ac01683e2d95072fda3980637fb86ea9f via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The identical skills-loss bug stays live on messaging: driver.py:773 sees the same "completed" event but this PR arms only the dashboard runner.

Watch

The PR's stated harm — "the next user turn can therefore no longer discover the skills available to the session" — applies equally to messaging: the driver handles EVENT_COMPACTION_STATUS (src/kiro_crew/messaging/driver.py:773) without arming, messaging serves manual /compact (commands.py:321), and its dispatch already consumes the flag (src/kiro_crew/messaging/dispatch.py:777). The spec hunk ("does not add skills reinjection to messaging surfaces or the task runner") records the gap but leaves the same user harm shipping on those surfaces, and the per-surface arming shape means each future surface must remember its own arm.
Clears when: the messaging driver's EVENT_COMPACTION_STATUS/wait_for_compaction completion paths arm the same flag (a near-identical one-liner), or a linked follow-up issue owns that surface explicitly.

[DESIGN-REVIEWED] a76f976

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🟡 CONCERNS

Premise-level review of a76f976ac01683e2d95072fda3980637fb86ea9f via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Dashboard-only arm: the same unarmed-reinjection gap stays at 17 counted compaction sites across 11 messaging surfaces and the task runner.

Not justified as shipped

  • Item 1 — symptom-level: the arm lands at the dashboard's three completion points while the identical gap persists at 17 wait_for_compaction sites across 11 surfaces (slack, telegram, discord, teams, webex, wecom, weixin, whatsapp, imessage, feishu, task_executor) plus messaging/driver.py:773 — all of which consume the flag (messaging/dispatch.py:777) and none of which arm it (grep mark_needs_reinjection: only session_compaction.py:650, chat_runner.py:14073, handlers/members.py:897). The deferral is declared only in the doc hunk ("does not add skills reinjection to messaging surfaces or the task runner"), never in the description.
    Clears when: the sibling surfaces' compaction-completion points arm the flag, or a linked issue records the deferral.

What this change ships

Inventory (4 items) — 3 justified

Intent: FIX — after any compaction completes, the next dashboard turn should still be able to discover the session's skills. Provenance: the new provider-native-status test fails on base.

  1. After a provider-initiated mid-turn compaction, the next dashboard turn regains the skills index — symptom-level (dashboard-only; counted siblings above)
  2. After manual /compact on an inline-compacting backend, the next dashboard turn regains the skills index — justified
  3. After a completed deferred /compact (not a failed one), the next dashboard turn regains the skills index — justified
  4. The memory-skills-hooks spec records the hook and its dashboard-only scope — justified

[FIRST-PRINCIPLES-REVIEWED] a76f976

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 7, 2026
@bolichen97
bolichen97 force-pushed the upstream/native-compaction-context-recovery branch from df70886 to a3c3fbb Compare September 8, 2026 10:11
@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main 6fbb06bcd by a maintainer as part of the 2026-09-08 open-PR audit. The branch was 163 commits behind; it is now a single commit on current main.

Conflicts: none — clean rebase, diff unchanged at +38/-0 in 2 files.

Gates run locally (changed files only): black --check, isort --check-only, flake8 all clean; pytest test/test_dashboard_chat.py -n0 → 769 passed.

Please review the rebased head. Note that a maintainer push makes the maintainer the last pusher, so under this repo's last-push rule a second approver is needed before merge. Reply here if anything looks wrong.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 8, 2026
@Premshay
Premshay force-pushed the upstream/native-compaction-context-recovery branch from a3c3fbb to 0c0ca70 Compare September 9, 2026 15:41
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Sep 9, 2026
Provider-native compaction drops session-start context. Re-arm the existing one-shot skills reinjection after confirmed success so the next turn retains the available skills.
@Premshay
Premshay force-pushed the upstream/native-compaction-context-recovery branch from 0c0ca70 to a76f976 Compare September 16, 2026 23:10
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 16, 2026
@NicholasRBowers
NicholasRBowers enabled auto-merge (squash) September 17, 2026 00:27

@NicholasRBowers NicholasRBowers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: fix with a clear root cause — confirmed compaction completion never armed the existing one-shot skills-context reinjection flag, so the next dashboard turn ran without its session-start skills context; the change arms that flag at the three confirmed-completion points and leaves failed deferred compaction unarmed. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/memory-skills-hooks.md. CodeQL is not applicable on this fork PR (default-setup emits no check-run); SAST coverage is Semgrep only, latest run success with 0 annotations.

@NicholasRBowers
NicholasRBowers merged commit 1d6dd26 into kirodotdev:main Sep 17, 2026
86 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 17, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
Provider-native compaction drops session-start context. Re-arm the existing one-shot skills reinjection after confirmed success so the next turn retains the available skills.

Co-authored-by: Premshay <28099628+Premshay@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants